﻿namespace com.oakwoodsys.Web
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;

    public class HtmlInputButtonControl : HtmlInputButton
    {
        #region Constructors

        public HtmlInputButtonControl( )
            : base()
        {
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Gets or sets the HTML background color style.
        /// </summary>
        public string BackgroundColor
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the HTML border style.
        /// </summary>
        public string Border
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the CSS margin properties. 
        /// Example 1: Margin = "25px 50px 75px 100px" is top margin 25px, right margin 50px, bottom margin 75px, left margin 100px
        /// Example 2: Margin = "25px 50px 75px" is top margin 25px, right and left margins 50px, bottom margin 75px
        /// Example 3: Margin = "25px 50px" is top and bottom margins 25px, right and left margins 50px
        /// Example 4: Margin = "25px" is all four margins are 25px
        /// </summary>
        public string Margin
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the HTML onclick action.
        /// </summary>
        public string OnClickAction
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the CSS padding properties. 
        /// Example 1: Padding = "25px 50px 75px 100px" is top padding 25px, right padding 50px, bottom padding 75px, left padding 100px
        /// Example 2: Padding = "25px 50px 75px" is top padding 25px, right and left paddings 50px, bottom padding 75px
        /// Example 3: Padding = "25px 50px" is top and bottom paddings 25px, right and left paddings 50px
        /// Example 4: Padding = "25px" is all four paddings are 25px
        /// </summary>
        public string Padding
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the caption or title of the control.
        /// </summary>
        public string Text
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the CSS text-decoration property that is added to the text.
        /// </summary>
        public string TextDecoration
        {
            get;
            set;
        }

        #endregion Properties

        #region Methods

        protected override void OnPreRender( EventArgs e )
        {
            if ( !string.IsNullOrEmpty( Border ) )
                this.Attributes.CssStyle.Add( "border", Border );
            if ( !string.IsNullOrEmpty( BackgroundColor ) )
                this.Attributes.CssStyle.Add( HtmlTextWriterStyle.BackgroundColor, BackgroundColor );
            if ( !string.IsNullOrEmpty( Margin ) )
                this.Attributes.CssStyle.Add( "margin", Margin );
            if ( !string.IsNullOrEmpty( OnClickAction ) )
                this.Attributes.Add( "onclick", OnClickAction );
            if ( !string.IsNullOrEmpty( Padding ) )
                this.Attributes.CssStyle.Add( "padding", Padding );
            if ( !string.IsNullOrEmpty( Text ) )
                this.Attributes.Add( "value", Text );
            if ( !string.IsNullOrEmpty( TextDecoration ) )
                this.Attributes.CssStyle.Add( "text-decoration", TextDecoration );
        }

        #endregion Methods

        #region Nested Types

        public class BackgroundColorConsts
        {
            #region Fields

            public const string Transparent = "transparent";

            #endregion Fields
        }

        public class BorderConsts
        {
            #region Fields

            public const string None = "none";

            #endregion Fields
        }

        public class TextDecorationConsts
        {
            #region Fields

            public const string LineThrough = "line-through";
            public const string Overline = "overline";
            public const string Underline = "underline";

            #endregion Fields
        }

        #endregion Nested Types
    }
}